package edu.ynu.se.xiecheng.achitectureclass.dao;

import edu.ynu.se.xiecheng.achitectureclass.common.dao.LogicDAO;
import edu.ynu.se.xiecheng.achitectureclass.entity.*;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

public interface CustomerDao extends LogicDAO<Customer,Long> {
    @Query("SELECT s FROM Shop s WHERE s.business = :business")
    List<Shop> getShopsByBusiness(@Param("business") Business business);

    @Query("SELECT i FROM Item i WHERE i.shopItem = :shop")
    List<Item> getItemsByShop(@Param("shop") Shop shop);


    @Transactional
    @Modifying
    @Query("UPDATE Orders o SET o.isPaid = '已支付' WHERE o.id = :orderId")
    void payOrder(@Param("orderId") Long orderId);
}
